#!/bin/sh



#GLOBAL
CIPHER=-sha512
POWER=8192
DAYS=3000

DIR_CERT=./certs/




#Urząd Certyfikacji
SUBJECT='/C=PL/ST=DolnySlask/L=Wroclaw/O=BlackNet Certs/CN=BlackNet'
PASSWORD_CA=50d3ae\$wa#a431
FILE_NAME_CA=$DIR_CERT"blacknet_CA"


#Generowanie Certa
openssl req -x509 $CIPHER -newkey rsa:$POWER -passout pass:$PASSWORD_CA -keyout $FILE_NAME_CA.key -out $FILE_NAME_CA.pem  -subj "$SUBJECT"  -days $DAYS





#Baduga
SUBJECT='/C=PL/ST=DolnySlask/L=Wroclaw/O=Wroclaw University of Technology/CN=fearless-guardians.no-ip.info'
PASSWORD=5edQae\$wa#a4W1


FILE_NAME=baduga_cert
FILE_NAME_S=$DIR_CERT"$FILE_NAME"_srv
FILE_NAME_C=$DIR_CERT"$FILE_NAME"_cli


#Generowanie Certa
openssl req $CIPHER -newkey rsa:$POWER -passout pass:$PASSWORD -keyout $FILE_NAME_S.key -out $FILE_NAME_S.req  -subj "$SUBJECT"  -days $DAYS

#Sygnowanie Keya
openssl x509 -req -in $FILE_NAME_S.req -CAkey $FILE_NAME_CA.key -CA $FILE_NAME_CA.pem -CAserial $FILE_NAME_CA.srl  -passin pass:$PASSWORD_CA -out $FILE_NAME_S.pem -days $DAYS




PASSWORD=9edQae\$waNQE3s#aZW1


#Generowanie Certa
openssl req $CIPHER -newkey rsa:$POWER -passout pass:$PASSWORD -keyout $FILE_NAME_C.key -out $FILE_NAME_C.req  -subj "$SUBJECT"  -days $DAYS

#Sygnowanie Keya
openssl x509 -req -in $FILE_NAME_C.req  -CAkey $FILE_NAME_CA.key -CA $FILE_NAME_CA.pem -CAserial $FILE_NAME_CA.srl -passin pass:$PASSWORD_CA -out $FILE_NAME_C.pem -days $DAYS







#generowanie klucza
#openssl genrsa $CIPHER -passout pass:$PASSWORD -out $DIR_CERT$FILE_NAME.key $POWER

#Generowanie Certa
#openssl req -x509 $CIPHER -newkey rsa:$POWER -passout pass:$PASSWORD -keyout $DIR_CERT$FILE_NAME_S.key -out $DIR_CERT$FILE_NAME_S.crt  -subj "$SUBJECT"  -days $DAYS

#Generowanie Public
#openssl x509 -pubkey -noout -in $DIR_CERT$FILE_NAME_S.crt -passin pass:$PASSWORD  >> "$DIR_CERT"pub_"$FILE_NAME_C".pem
